package cn.pugle.ormtest;

import cn.pugle.ormtest.ebean.EbeanDemo;
import cn.pugle.ormtest.hibernate.JpaHibernateDemo;
import cn.pugle.ormtest.jdbctemplate.JdbcTemplateDemo;
import cn.pugle.ormtest.mybatis.MybatisDemo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.PropertySources;

@SpringBootApplication
@PropertySources({
        @PropertySource("classpath:application.properties"),
        @PropertySource("classpath:hibernate/hibernate.properties"),
        @PropertySource("classpath:mybatis/mybatis.properties")
})
//@EnableJpaRepositories(basePackages = "cn.pugle.ormtest.hibernate")//why this line doesnt work for me?
@EntityScan(basePackages = "cn.pugle.ormtest.hibernate")
public class OrmtestApplication implements CommandLineRunner {


    public static void main(String[] args) {
        SpringApplication.run(OrmtestApplication.class, args);
    }


    @Autowired
    private JdbcTemplateDemo jdbcTemplateDemo;
    @Autowired
    private MybatisDemo mybatisDemo;
    @Autowired
    private EbeanDemo ebeanDemo;
    @Autowired
    private JpaHibernateDemo hibernateDemo;

    @Override
    public void run(String... strings) throws Exception {
//        System.out.println("-------------jdbcTemplate-------------");
//        jdbcTemplateDemo.retrieve();
//        System.out.println("-------------mybatis------------------");
//        mybatisDemo.retrieve();
//        System.out.println("-------------ebean--------------------");
//        ebeanDemo.create();
//        ebeanDemo.retrieve();
//        ebeanDemo.update();
//        ebeanDemo.delete();
//        ebeanDemo.rawSQL();
//        ebeanDemo.join();

        System.out.println("-------------hibernate--------------------");
//        hibernateDemo.create();
//        hibernateDemo.retrieve();
//        hibernateDemo.update();
//        hibernateDemo.delete();
        hibernateDemo.rawSQL();
    }
}
